<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
  	<spring:theme code="styleSheet" var="roo_css"/>
  	<spring:url value="/${roo_css}" var="roo_css_url"/>
  	<spring:url value="/resources/images/favicon.ico" var="favicon"/>
    <spring:url value="/resources/js-framework/jquery-1.7.2.min.js" var="jquery_url"/>
	<spring:url value="/resources/js-framework/jquery-ui/jquery-ui-1.8.22.custom.min.js" var="jquery_ui_1_8_21_custom_min_js"/>
	<spring:url value="/resources/js-framework/jquery-ui/combobox.js" var="combobox_js"/>
	<spring:url value="/resources/js-framework/jquery-ui/css/ui-darkness/jquery-ui-1.8.22.custom.css" var="jquery_ui_1_8_21_custom_css"/>
	<spring:url value="/resources/js-framework/form2js/form2js.js" var="form2js_js"/>
	<spring:url value="/resources/js-framework/form2js/jquery.toObject.js" var="jquery_toObject_js"/>
	<spring:url value="/resources/js-framework/form2js/js2form.js" var="js2form_js"/>
	<spring:url value="/resources/js-framework/form2js/json2.js" var="json2_js"/>
	<spring:url value="/resources/js-framework/validate/jquery.validate.min.js" var="jquery_validate_min_js"/>
	<spring:url value="/resources/js-framework/validate/additional-methods.min.js" var="additional_methods_min_js"/>
	
	<link rel="stylesheet" type="text/css" href="${jquery_ui_1_8_21_custom_css}" media="screen" />
    <!-- Get the user local from the page context (it was set by Spring MVC's locale resolver) -->
    <c:set var="userLocale">
      <c:set var="plocale">${pageContext.response.locale}</c:set>
      <c:out default="en" value="${fn:replace(plocale, '_', '-')}"/>
    </c:set>
	<script src="${jquery_url}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
    <script src="${jquery_ui_1_8_21_custom_min_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
    <script src="${combobox_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
	<script src="${json2_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
	<script src="${form2js_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
    <script src="${jquery_toObject_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
    <script src="${js2form_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
	<script src="${jquery_validate_min_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
    <script src="${additional_methods_min_js}" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
    
      <script src="../js-user/application.js" type="text/javascript">
        <!-- required for FF3 and Opera -->
    </script>
   
    <script  type="text/javascript">
    jQuery.fn.reset = function () {
  	  $(this).each (function() { this.reset(); });
  	};
  	
  	
  	$.fn.serializeFormJSON = function() {
 		   var o = {};
 		   var a = this.serializeArray();
 		   $.each(a, function() {
 		       if (o[this.name]) {
		           if (!o[this.name].push) {
 		               o[this.name] = [o[this.name]];
 		           }
 		           o[this.name].push(this.value || '');
 		       } else {
 		           o[this.name] = this.value || '';
 		       }
 		   });
 		   return o;
 		};
 		
 		function _ajax_request(url, data, callback, type, method) {
 		    if (jQuery.isFunction(data)) {
 		        callback = data;
 		        data = {};
 		    }
 		    return jQuery.ajax({
 		        type: method,
 		        url: url,
 		        data: data? JSON.stringify(data) : null,
 		        success: callback,
 		        dataType: type,
 		     	contentType: "application/json; charset=utf-8"
 		        });
 		}

 		jQuery.extend({
	   		putJson: function(url, data, callback, type) {
	   		    return _ajax_request(url, data, callback, type, 'PUT');
	   		},
	   		deleteJson_: function(url, data, callback, type) {
	   		    return _ajax_request(url, data, callback, type, 'DELETE');
	   		},
	   		    
	   		 postJson: function (url, data, callback, type) {
	   			return _ajax_request(url, data, callback, type, 'POST');
	   		 }
 		});
 		
 		(function( $ ){
 		  $.fn.toDeepJson = function() {
 		    function parse(val){
 		      if (val == ""){ return null; }
 		      if (val == "true"){ return true; }
 		      if (val == "false"){ return false; }
 		      if (val == String(parseInt(val))){ return parseInt(val); }
 		      if (val == String(parseFloat(val))){ return parseFloat(val); }
 		      return val;      
 		    }
 		    function toNestedObject(obj, arr){
 		      var key = arr.shift();
 		      if (arr.length > 0) {
 		        obj[key] = toNestedObject(obj[key] || {}, arr);
 		        return obj;
 		      }
 		      return key;
 		    }
 		    if (this.length == 1){
 		      return $.makeArray(this[0].elements)
 		      .filter(function(e){
 		          return e.name && e.name != "" && (e.type == 'radio' ? e.checked : true);
 		      })
 		      .map(function(e){
 		          var names = e.name.split('.');
 		          if (e.type == 'checkbox') {
 		            e.value = e.checked;
 		          }
 		          names.push(parse(e.value));
 		          return names;
 		      })
 		      .reduce(toNestedObject, {});
 		    } else {
 		      throw({error:"Can work on a single form only"});
 		    }
 		  };

 		  $.flatten = function (obj){
 		    var ret = {};
 		    for (var key in obj){
 		      if (typeof obj[key] == 'object'){
 		        var fobj = $.flatten(obj[key]);
 		        for (var extkey in fobj){
 		          ret[key+"."+extkey] = fobj[extkey];
 		        }
 		      } else {
 		        ret[key] = String(obj[key]);
 		      }
 		    }
 		    return ret;
 		  };
 		  
 		})( jQuery );

    </script>
    
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<spring:message code="application_name" var="app_name" htmlEscape="false"/>
	<title><spring:message code="welcome_h3" arguments="${app_name}" /></title>
  	<link href="${favicon}" rel="SHORTCUT ICON"/>
  	<link href="${roo_css_url}" media="screen" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
	<div class="contentArea">
		<tiles:insertAttribute name="header" />        
         <div>
    		<div class="topSection">
                <div class="fl left"></div>
                <div class="fr right"></div>
                <div class="mid"></div>
                <div class="clear"></div>
       		</div>
        	<div class="midSection" style=" min-height:400px;">
                <!--left section-->
                <tiles:insertAttribute name="menu"  ignore="true"/>
                <!--left section-->
               	<tiles:insertAttribute name="body" />
           </div>
        	<div class="botSection">
        	<div class="fl left"></div>
    		<div class="fr right"></div>
    		<div class="mid"></div>
			<div class="clear"></div>
        </div>
		</div>
	     <tiles:insertAttribute name="footer" />
    </div>
</div>
</body>
</html>